/**
 * 
 */
package com.zhonggong.jdbcDemo;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.zhonggong.dao.IEmpDao;
import com.zhonggong.dao.impl.EmpDaoImpl;
import com.zhonggong.model.EmpObj;
import com.zhonggong.tools.DBUtil;

/**
 * @author Administrator
 *
 */
public class Test {
	/**
	 * @param args
	 * @throws SQLException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		// TODO Auto-generated method stub
		
		
		DBUtil.getConn();
		
		String sql = "insert into emp(e_name,e_age) values(?,?)";
		Object[] objects = {"zhangsan",22};
		int resultValue = DBUtil.update(sql, objects);
		System.out.println(resultValue);
		
		String sql1 = "select * from emp where e_age=?";
		Object[] objects2 = {22};
		ResultSet rSet = DBUtil.query(sql1, objects2);
		while (rSet.next()) {
			System.out.println(rSet.getString("e_name"));
		}
		
		DBUtil.close();
		
		IEmpDao empDao = new EmpDaoImpl();
		List<EmpObj> list = empDao.getAll();
		System.out.println(list);
		
	}

}
